Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Working With Alternate Tracks

The Movie Toolbox allows you to define alternate tracks in a movie. You can use alternate tracks to support multiple languages or to present different levels of visual quality in the movie. You collect alternate tracks into groups. Alternate track groups are collections of tracks that conceptually represent some data but are appropriate for use in different play environments. For example, you might have some 4-bit data in one track and some 8-bit data in another. Working with alternate tracks allows you to set up alternatives from which the Movie Toolbox can choose.

The Movie Toolbox selects one track from each alternate group when it plays the movie. For example, you could create a movie that has three separate audio tracks: one in English, one in French, and one in Spanish. You would collect these audio tracks into an alternate group. When the user plays the movie, the Movie Toolbox selects the track from this group that corresponds to the current language setting for the movie.

Similarly, you can use alternate tracks to store data of different quality. When the user plays the movie, the Movie Toolbox selects the track that best suits the capabilities of the Macintosh computer on which the movie is being played. In this manner, you can create a single movie that can accommodate the playback characteristics of a number of different computer configurations.

The Movie Toolbox allows you to store quality information for media structures that are assigned to either sound or video tracks. For all tracks, the Movie Toolbox uses bits 6 and 7 of the quality setting. These bits encode a relative quality value. These values range from 0 to 3. You can use higher quality values to indicate larger sample sizes. For example, consider a movie that has two sound tracks that are alternates for each other--one contains 8-bit sound while the other contains 16-bit sound. You could assign a quality value of mediaQualityNormal to the 8-bit media and a value of mediaQualityBetter to the 16-bit media. The Movie Toolbox would only play the 16-bit media if the Macintosh configuration could handle 16-bit sound. Otherwise, the Movie Toolbox would use the 8-bit media. The sound media handler determines the sample size for each sound media for the Movie Toolbox by examining the media's sound description structure.

In addition, the Movie Toolbox also uses bits 0 through 5 (the low-order bits) of the quality setting. You use these bits to indicate the pixel depths at which the media should be played. Each bit corresponds to a single depth value, ranging from 1-bit pixels to 32-bit pixels. You may use these bits to control the playback of both video and sound tracks.

As an example, consider a movie that contains three video tracks with the following characteristics:

Track A

1-bit video data, no compression

Track B

Compressed using the Apple Video Compressor

Track C

Compressed using the Joint Photographic Experts Group (JPEG) compressor

You could assign the following quality values to these track's media structures:

Track A

mediaQualityDraft + 1-bit depth + 2-bit depth (quality value is 0x0003: 0x0000 + 0x0003)

Track B

mediaQualityNormal + 4-bit depth + 8-bit depth + 16-bit depth + 32-bit depth (quality value is 0x007C: 0x0040 + 0x003C)

Track C

mediaQualityBetter + 4-bit depth + 8-bit depth + 16-bit depth + 32-bit depth (quality value is 0x00BC: 0x0080 + 0x003C)

The Movie Toolbox would always use Track A when playing the movie on 1-bit and 2-bit displays. At the other pixel depths, the video media handler determines which track to use by examining the availability and performance of the specified decompressors. If the JPEG decompressor can play back at full frame rate, the Movie Toolbox would use Track C. Otherwise, the Toolbox uses Track B. The video media handler determines the compressor that is appropriate for each media by examining the media's image description structure.

You set a movie's language by calling the SetMovieLanguage function.

To establish alternate groups of tracks, you can use the SetTrackAlternate and GetTrackAlternate functions.

You can work with the language and quality characteristics of media by calling the  GetMediaLanguage , SetMediaLanguage , GetMediaQuality , and SetMediaQuality functions.

By default, the Movie Toolbox automatically selects the appropriate tracks to play according to a movie's quality and language settings, as well as the capabilities of the Macintosh computer. Whenever your application calls the SetMovieGWorld , SetMovieBox , UpdateMovie , or SetMovieMatrix function (described on SetMovieGWorld , SetMovieBox , UpdateMovie , and SetMovieMatrix , respectively), the Movie Toolbox checks each alternate group for an appropriate track. However, you can control this selection process. Use the SetAutoTrackAlternatesEnabled function to enable or disable automatic track selection. The SelectMovieAlternates function instructs the Movie Toolbox to select appropriate tracks immediately. If no tracks in an alternate track group are enabled, then the Movie Toolbox does not activate any track from that group during automatic track selection.

SetMovieLanguage

The SetMovieLanguage function allows your application to specify a movie's language. You specify the language by supplying the appropriate language or region code (see Inside Macintosh: Text for more information on language and region codes).

pascal void SetMovieLanguage (Movie theMovie, long language);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

language
Specifies the movie's language or region code.

DESCRIPTION

The Movie Toolbox examines the movie's alternate groups and selects and enables appropriate tracks. If the Movie Toolbox cannot find an appropriate track, it does not change the movie's language.

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SelectMovieAlternates

The SelectMovieAlternates function allows your application to instruct the Movie Toolbox to select appropriate tracks immediately.

pascal void SelectMovieAlternates (Movie theMovie);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

DESCRIPTION

You can call the SelectMovieAlternates function even if you have disabled automatic track selection with the SetAutoTrackAlternatesEnabled function (which is described in the next section) or by setting the newMovieDontAutoAlternate flag when you created the movie (see newMovieDontAutoAlternate for details on this flag).

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SetAutoTrackAlternatesEnabled

The SetAutoTrackAlternatesEnabled function allows your application to enable and disable automatic track selection by the Movie Toolbox.

pascal void SetAutoTrackAlternatesEnabled (Movie theMovie,
                                         Boolean enable);
theMovie
Specifies the movie for this operation. Your application obtains this movie identifier from such functions as NewMovie , NewMovieFromFile , and NewMovieFromHandle (described on NewMovie , NewMovieFromFile , and NewMovieFromHandle , respectively).

enable
Controls automatic track selection. Set this parameter to true to enable automatic track selection. Set this parameter to false to disable automatic track selection.

DESCRIPTION

If automatic track selection is enabled, the Movie Toolbox selects appropriate tracks whenever your application calls the SetMovieGWorld , SetMovieBox , UpdateMovie , or SetMovieMatrix functions (described on SetMovieGWorld , SetMovieBox , UpdateMovie , and SetMovieMatrix , respectively). When you enable automatic track selection, the Movie Toolbox immediately selects enabled tracks for the movie. This overrides the setting of the newMovieDontAutoAlternate flag (see newMovieDontAutoAlternate for details on this flag).

ERROR CODES

invalidMovie

-2010

This movie is corrupted or invalid

SEE ALSO

You can instruct the Movie Toolbox to select appropriate tracks immediately by calling the SelectMovieAlternates function, which is described in the previous section.

SetTrackAlternate

The SetTrackAlternate function allows your application to add tracks to or remove tracks from alternate groups.

pascal void SetTrackAlternate (Track theTrack, Track alternateT);
theTrack
Specifies the track and group for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively). The SetTrackAlternate function changes this track's group affiliation based on the value of the alternateT parameter.

alternateT
Controls whether the function adds the track to a group or removes it from a group. If the alternateT parameter contains a valid track identifier, the Movie Toolbox adds this track to the group that contains the track specified by the parameter theTrack . Note that if the track identified by the parameter alternateTrack already belongs to a group, the Movie Toolbox combines the two groups into a single group.

Set this parameter to nil to remove the track specified by the theTrack parameter from its group.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

You can determine all the tracks in a group by calling the GetTrackAlternate function, which is described in the next section.

GetTrackAlternate

The GetTrackAlternate function allows your application to determine all the tracks in an alternate group. You specify the group by identifying a track in the group. The group list is circular, so you must specify a different track in the group each time you call this function.

pascal Track GetTrackAlternate (Track theTrack);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

DESCRIPTION

The GetTrackAlternate function returns the track identifier of the next track in the group. If the track you specify does not belong to a group, the function returns the same identifier you supply. Because the alternate group list is circular, you have retrieved all the tracks in the group when the function returns the track identifier that you supplied the first time you called the GetTrackAlternate function. If there is only one track in an alternate group, this function returns the track identifier you supply.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

SEE ALSO

You can add a track to a group by calling the SetTrackAlternate function, which is described in the previous section.

SetMediaLanguage

The SetMediaLanguage function sets a media's language or region code. You should call this function only when you are creating a new media. See Inside Macintosh: Text for more information on language and region codes.

pascal void SetMediaLanguage (Media theMedia, short language);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewMovieTrack and GetMovieTrack , respectively).

language
Specifies the media's language or region code.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

SEE ALSO

You can retrieve a media's language or region code by calling the GetMediaLanguage function, which is described in the next section.

GetMediaLanguage

The GetMediaLanguage function returns a media's language or region code. See Inside Macintosh: Text for more information on language and region codes.

pascal short GetMediaLanguage (Media theMedia);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

SEE ALSO

You can set a media's language or region code by calling the SetMediaLanguage function, which is described in the previous section.

SetMediaQuality

The SetMediaQuality function sets a media's quality level value. The Movie Toolbox uses this quality value to determine which track it selects to play on a given Macintosh computer. You should set this value only when you are creating a new media.

pascal void SetMediaQuality (Media theMedia, short quality);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

quality
Specifies the media's quality value. The quality value indicates the pixel depths at which the media can be played. This even applies to sound media. The low-order 6 bits of the quality value correspond to specific pixel depths. If a bit is set to 1, the media can be played at the corresponding depth. More than one of these bits may be set to 1. The following bits are defined:

Bit 0

1 bit per pixel

Bit 1

2 bits per pixel

Bit 2

4 bits per pixel

Bit 3

8 bits per pixel

Bit 4

16 bits per pixel

Bit 5

32 bits per pixel


In addition, bits 6 and 7 define the media's quality level. A value of 0 corresponds to the lowest quality level; a value of 3 corresponds to the highest quality level. The following constants define these values:

mediaQualityDraft
Specifies the lowest quality level. This constant sets bits 6 and 7 to a value of 0.

mediaQualityNormal
Specifies an acceptable quality level. This constant sets bits 6 and 7 to a value of 1.

mediaQualityBetter
Specifies a higher quality level. This constant sets bits 6 and 7 to a value of 2.

mediaQualityBest
Specifies the highest quality level. This constant sets bits 6 and 7 to a value of 3.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

SEE ALSO

You can retrieve the quality value of a media by calling the GetMediaQuality function, which is described in the next section.

GetMediaQuality

The GetMediaQuality function returns a media's quality level value. The Movie Toolbox uses this quality value to influence which track it selects to play on a given Macintosh computer.

pascal short GetMediaQuality (Media theMedia);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

DESCRIPTION

The GetMediaQuality function returns the media's quality value. The quality value indicates the pixel depths at which the media can be played. This even applies to sound media. The low-order 6 bits of the quality value correspond to specific pixel depths. If a bit is set to 1, the media can be played at the corresponding depth. More than one of these bits may be set to 1. The following bits are defined:

Bit 0

1 bit per pixel

Bit 1

2 bits per pixel

Bit 2

4 bits per pixel

Bit 3

8 bits per pixel

Bit 4

16 bits per pixel

Bit 5

32 bits per pixel

In addition, bits 6 and 7 define the media's quality level. A value of 0 corresponds to the lowest quality level; a value of 3 corresponds to the highest quality level.

mediaQualityDraft
Specifies the lowest quality level. This constant sets bits 6 and 7 to a value of 0.

mediaQualityNormal
Specifies an acceptable quality level. This constant sets bits 6 and 7 to a value of 1.

mediaQualityBetter
Specifies a higher quality level. This constant sets bits 6 and 7 to a value of 2.

mediaQualityBest
Specifies the highest quality level. This constant sets bits 6 and 7 to a value of 3.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

SEE ALSO

You can set the quality value of a media by calling the SetMediaQuality function, which is described in the previous section.


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next